<script>
$(function() {
	$( "#tabs" ).tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    },
	selected: 0
	});
});
</script>
<div id="tabs">
	<ul>
            <li><a href='#pt'>Thu - Chi</a> </li>
            <li><?php echo $this->Html->link(__('Thêm thu - chi', true), array('controller'=>'chiphikhoas','action' => 'add',$khoa_id)); ?></li>
            <li><?php echo $this->Html->link(__('Biểu đồ', true), array('controller'=>'chiphikhoas','action' => 'bieudo',$khoa_id)); ?></li>
           <li><?php echo $this->Html->link(__('Thống kê thu - chi', true), array('controller'=>'chiphikhoas','action' => 'tkthuchi',$khoa_id)); ?></li>
    </ul>
<div class="Chiphikhoas index">
<?php
if(!empty($rows)&&!empty($cols)&&!empty($data))
	echo $ctable->thu_chi($rows, $cols, $data);?>
<br>
<?php echo $form->create('Chiphikhoa');?>
<?php echo $form->input('namhoc_id',array('id'=>'namhoc_id','label'=>'Năm học: ','type'=>'select','options'=>$namhocs,'selected'=>$namhoc));?>
<?php echo $form->end();?>
<div id='div_thuchi'>
<h2 style="text-align: center;"><?php __('Thu - Chi của Đoàn khoa trong năm học '.$this->Session->read('namhocht_ten'));?></h2>
<?php echo $html->link('Xuất excel',array('controller'=>'chiphikhoas','action'=>'xuatexcelthuchi',$khoa_id,$namhoc))?>
	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Ngày Thu(Chi)';?></th>
			<th><?php echo 'Loại Phí';?></th>
			<th><?php echo 'Số Tiền (VNĐ)';?></th>
			<th><?php echo 'Lý Do';?></th>
			<th><?php echo 'Người Nhận';?></th>
			<th><?php echo 'Ghi Chú';?></th>
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
	<?php
	$i = 1;
	foreach ($chiphikhoas as $chiphikhoa):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $i; ?>&nbsp;</td>
		<td><?php echo date('d-m-Y',strtotime($chiphikhoa['Chiphikhoa']['ngaynhan'])); ?>&nbsp;</td>
		<td><?php echo $chiphikhoa['Loaichiphi']['tenloaichiphi']; ?></td>
		<td><?php echo number_format($chiphikhoa['Chiphikhoa']['sotien'],0,',','.'); ?>&nbsp;</td>
		<td><?php echo $chiphikhoa['Chiphikhoa']['lydo']; ?>&nbsp;</td>
		<td><?php echo $chiphikhoa['Chiphikhoa']['nguoinhantien']; ?>&nbsp;</td>
		<td><?php echo $chiphikhoa['Chiphikhoa']['ghichu']; ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('Sửa', true), array('action' => 'edit',$chiphikhoa['Chiphikhoa']['id'],$chiphikhoa['Chiphikhoa']['khoa_id'],)); ?>
			<?php echo $this->Html->link(__('Xóa', true), array('action' => 'delete',$khoa_id,$namhoc,$chiphikhoa['Chiphikhoa']['id']), null, sprintf(__('Bạn muốn xóa %s?', true), $chiphikhoa['Loaichiphi']['tenloaichiphi'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
<tr>
	<td><?php echo $i; ?>&nbsp;</td>
		<td>&nbsp;</td>
		<td><?php echo 'Thu Đoàn phí'?></td>
		<td><?php echo number_format($dpht,0,',','.'); ?>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td class="actions">
		</td>
	</tr>
	</table>
	<p>
	<?php
	$paginator->options(array('url'=>array('controller'=>'chiphikhoas','action'=>'thuchi',$khoa_id,$namhoc)));
	echo $this->Paginator->counter(array(
	'format' => __('Trang %page%/%pages%, hiện có %count% mẫu tin', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('Trước', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('Sau', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
</div>
<?php
$this->Js->get('#namhoc_id')->event('change',
							$this->Js->request(array('controller' => 'chiphikhoas', 'action' => 'updatethuchi',$khoa_id),
							array('update' => '#div_thuchi','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true))))); 
?>